/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package services;

import beans.GetFriendListBean;
import java.util.List;
import java.util.Map;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PUT;
import javax.ws.rs.QueryParam;
import org.jboss.logging.Param;
import org.json.JSONObject;

/**
 * REST Web Service
 *
 * @author tae
 */
@Path("resource/GetFriendList")
@Stateless
public class GetFriendListResource {

    @Context
    private UriInfo context;
    
    @EJB
    private GetFriendListBean bean;

    /**
     * Creates a new instance of GetFriendListResource
     */
    public GetFriendListResource() {
    }

    /**
     * Retrieves representation of an instance of services.GetFriendListResource
     * @param senderid
     * @return an instance of java.lang.String
     */
    @POST
    @Produces("application/json")
    public String execute(@FormParam("senderid") long senderid) {
        System.out.println("GetFriendListResource executed" + senderid);
        
        List<Map<String, Object>> list = bean.getFriendList(senderid);
            
        JSONObject outJSON = new JSONObject();
        outJSON.put("friendList", list);
        
        return outJSON.toString();
    }
}
